package com.luo.chengrui.module.sa.service.datapermission;

import com.luo.chengrui.module.sa.service.datapermission.DataPermissionConfigExcludeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import org.springframework.validation.annotation.Validated;

import java.util.*;

import com.luo.chengrui.module.sa.controller.admin.datapermission.vo.*;
import com.luo.chengrui.module.sa.dal.dataobject.datapermission.DataPermissionConfigExcludeDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;

import com.luo.chengrui.module.sa.convert.datapermission.DataPermissionConfigExcludeConvert;
import com.luo.chengrui.module.sa.dal.mysql.datapermission.DataPermissionConfigExcludeMapper;

import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.luo.chengrui.module.sa.enums.ErrorCodeConstants.*;;

/**
 * 数据权限继承排除表 记录从上级机构继承并排除权限配置项。 Service 实现类
 *
 * @author luodz
 */
@Service
@Validated
public class DataPermissionConfigExcludeServiceImpl implements DataPermissionConfigExcludeService {

    @Resource
    private DataPermissionConfigExcludeMapper dataPermissionConfigExcludeMapper;

    @Override
    public String createDataPermissionConfigExclude(DataPermissionConfigExcludeCreateReqVO createReqVO) {
        // 插入
        DataPermissionConfigExcludeDO dataPermissionConfigExclude = DataPermissionConfigExcludeConvert.INSTANCE.convert(createReqVO);
        dataPermissionConfigExcludeMapper.insert(dataPermissionConfigExclude);
        // 返回
        return dataPermissionConfigExclude.getId();
    }

    @Override
    public void deleteDataPermissionConfigExclude(String id) {
        // 删除
        dataPermissionConfigExcludeMapper.deleteById(id);
    }

    @Override
    public void deleteByConfigId(String configId) {
        dataPermissionConfigExcludeMapper.deleteByConfigId(configId);
    }
}
